package cc.mrbird.febs.item.controller;

import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.domain.QueryRequest;
import cc.mrbird.febs.item.domain.ItemBean;
import cc.mrbird.febs.item.domain.UserItemBean;
import cc.mrbird.febs.item.service.ItemService;
import cc.mrbird.febs.item.service.UserItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("item")
public class ItemController  extends BaseController {
    private String message;

    @Autowired
    private ItemService itemService;

    @Autowired
    private UserItemService userItemService;

    @GetMapping("item")
    public Map<String, Object> listItemById(QueryRequest queryRequest, ItemBean itemBean) {
        return getDataTable(itemService.listItemById(itemBean, queryRequest));
    }

    @GetMapping("user/item")
    public Map<String, Object> listItemByUser(QueryRequest queryRequest, UserItemBean userItemBean) {
        return getDataTable(itemService.listItemByUser(userItemBean, queryRequest));
    }

    @GetMapping("itemAll")
    public List<ItemBean> getItem() {
        List<ItemBean> list = this.itemService.listItem();
        return list;
    }

    @GetMapping("userAll")
    public List<UserItemBean> getUserItem() {
        List<UserItemBean> list = this.userItemService.listUser();
        return list;
    }
}
